You Are What You Eat
Eating fresh fruits and vegetables keeps fat and calories low. Use this program to chart your progress.
The current enthusiasm for choosing a healthy diet motivates people to keep track of the calories, fat, and cholesterol they consume. Suppose you were asked to design a program to help. This case study describes how a programmer might respond.
Problem Statement
Our friend Terry is just learning about computers and comes to us with a request. It sounds straight forward so we agree to help. Here is our conversation.
TERRY: Can you write a program for my new home computer to help me keep track of my diet? My computer is the same brand as yours.
MIKE AND MARCIA: What should the program do?
TERRY: Well, I want it to keep track of the fat and calories in the food I eat, figure out daily averages, and stuff like that. I've been using pencil and paper, but I lose track.
MIKE AND MARCIA: A running thirty-day average would be easy to compute. We could even have it graph your last thirty days of fat and calories if you want.
TERRY: Great!
MIKE AND MARCIA: We're still a bit confused, though. When you run the program, what do you expect to give it as input?
TERRY: Well, now I write down the fat and calories for everything I eat. I want to give the program all those numbers each day.
MIKE AND MARCIA: So the program should total them all up to get your daily total for fat and calories.
TERRY: It can do that, right?
MIKE AND MARCIA: Yes, that will be easy. You'll run the program every day?
Terry: Right.
MIKE AND MARCIA: And, you want the average and the graph printed every day. Let's see, for a graph it would help to know the maximum number of fat and calories to expect. What have the values been like?
TERRY: I've never eaten more than 6000 calories in a day. I think the fat has been as high as 400 grams, but I'm working on lowering that.
MIKE AND MARCIA: Wc Can display the graph on the screen. Is your screen just like ours?
TERRY: They look the same.
MIKE AND MARCIA: Do you have a disk drive on your computer? The program will need to keep a permanent file on your disk.
TERRY: Yes, it has a hard disk. Will that do?
MIKE AND MARCIA: Yes. Give us a few days and we'll come up with something you can try out.
TERRY: Great!